<?php
echo $this->Session->flash();
echo $this->Session->flash('good');
echo $this->Session->flash('bad');
?>

<table cellpadding="0" cellspacing="0" class="table-listing">
    <tr>
        <th class="col-no"><input type="checkbox" id="check-all" title="<?php echo __('Check All') ?>" class="rcheckbox" /></th>
        <th class="post-img-small"><?php echo __('Image') ?></th>
        <th><?php echo $this->Paginator->sort('title'); ?></th>
        <th><?php echo $this->Paginator->sort('category_id'); ?></th>
        <th><?php echo $this->Paginator->sort('created_at'); ?></th>
        <th><?php echo $this->Paginator->sort('created_by'); ?></th>
        <th><?php echo $this->Paginator->sort('status'); ?></th>
        <th class="actions"><?php echo __('Actions'); ?></th>
    </tr>
    <?php foreach ($posts as $post): ?>
        <tr class="tr-row">
            <td class="col-no"><input type="checkbox" id="check-item-<?php echo $post['Post']['id']; ?>" class="check-item" /> </td>
            <td class="post-img-small canclick">
                <?php
                echo $this->Html->link($this->Posts->thumbSmall($post), array('controller' => 'Posts', 'action' => 'view', $post['Post']['id']), array('escape' => false));
                ?>
            </td>
            <td class="canclick"><?php echo h($post['Post']['title']); ?>&nbsp;</td>
            <td class="canclick">
                <?php echo $this->Html->link($post['Category']['name'], array('controller' => 'categories', 'action' => 'view', $post['Category']['id'])); ?>
            </td>
            <td class="canclick"><?php echo h($post['Post']['created_at']); ?>&nbsp;</td>
            <td class="canclick"><?php echo h($post['Author']['email']); ?></td>
            <td class="status-col canclick"><?php echo $this->Posts->showStatus($post['Post']['id'], $post['Post']['status']); ?></td>
            <td class="actions action-cm3">
                <?php echo $this->Html->link(__('View'), array('admin' => true, 'action' => 'view', $post['Post']['id']), array('class' => 'act-lk show-link')); ?>
                <?php echo $this->Html->link(__('Edit'), array('admin' => true, 'action' => 'edit', $post['Post']['id']), array('class' => 'act-lk edit-link')); ?>
                <?php echo $this->Form->postLink(__('Delete'), array('admin' => true, 'action' => 'delete', $post['Post']['id']), array('class' => 'act-lk del-link'), __('Are you sure you want to delete # %s?', $post['Post']['id'])); ?>
            </td>
        </tr>
    <?php endforeach; ?>
</table>
<p>
    <?php
    echo $this->Paginator->counter(array(
        'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
    ));
    ?>	
</p>

<div class="paging">
    <?php
    echo $this->Paginator->prev('< ' . __('previous'), array(), null, array('class' => 'prev disabled'));
    echo $this->Paginator->numbers(array('separator' => ''));
    echo $this->Paginator->next(__('next') . ' >', array(), null, array('class' => 'next disabled'));
    ?>
</div>

<script type="text/javascript">
    jQuery(document).ready(function() {
        if (jQuery("#badMessage")) {
            jQuery("#badMessage").delay(10000).fadeOut(400);
        }

        if (jQuery("#goodMessage")) {
            jQuery("#goodMessage").delay(10000).fadeOut(400);
        }
    });
</script>
